<?php
	class main extends BaseController{
		public function getData($in_params){
			try {
				if(isset($_REQUEST['template'], $_REQUEST['controller_path']) && file_exists(constant('TEMPLATE_DIR').$_REQUEST['controller_path'])){
					// call perform actions on them
					general::debug('template', constant('TEMPLATE_DIR').$_REQUEST['controller_path']);
					include_once(constant('TEMPLATE_DIR').$_REQUEST['controller_path']);
					
					// TODO better handling actions
					// TODO vetter handling action results
					
					// get rid of the extension
					$classnmae = explode('.', $_REQUEST['controller']);
					$classnmae = $classnmae[0]; 
					$obj = new $classnmae;
					$obj->performActions($_REQUEST);
					$obj->view = TEMPLATE_DIR.$_REQUEST['view_path'];
					general::debug('view', $obj->view);
					$this->template_data['page'] = $obj->getContent($_REQUEST);
					
				} else {
					throw new Exception('Požadovaná stránka sa nenašla.'); // we have error in url - display according error
				}	
			} catch (Exception $e){
				include_once(constant('TEMPLATE_DIR').'error/error.php');
				$error = new error();
				$this->template_data['page'] = $error->getContent(array('error' => $e));		
			}
		}
	}
?>